create database BanHang_Pallet
go
use BanHang_Pallet
go
create table Loai
(
Id int identity(1,1) primary key not null,
Tenloai Nvarchar(max)null
)
go
create table Khachhang
(
Id int identity(1,1) primary key not null,
Tenkhachhang Nvarchar(max) null,
Tendangnhap varchar(max) null,
Matkhau Nvarchar(max) null,
Email Nvarchar(max) null,
Diachi Nvarchar(max) null,
Sodienthoai varchar(max)null
)
go
 create table Sanpham
 (
 Id Nvarchar(50) primary key not null,
 LoaiId int not null,
 Tensanpham Nvarchar(max) null,
 Gia Nvarchar(max) null,
 Chatlieu Nvarchar(max) null,
 Quycach Nvarchar(max)null,
 Mattren Nvarchar(max) null,
 Matduoi Nvarchar(max) null,
 Do Nvarchar(max) null,
 Solanxem int null,
 Hangmoi float null,
 Hinh Nvarchar(50) null, 
 foreign key (LoaiId) references Loai(Id)
 on delete cascade on update cascade,
 )
 
go

create table Gopy
(
Id int identity(1,1) primary key not null,
KhachhangId int,
SanphamId Nvarchar(50),
Ghichu Nvarchar(max) null,
foreign key (KhachhangId) references Khachhang(Id)
 on delete cascade on update cascade,
foreign key (SanphamId) references Sanpham(Id)
 on delete cascade on update cascade
)

go

create table Myadmin
(
Id int identity(1,1) primary key not null,
Tendangnhap Nvarchar(max) not null,
Tenhienthi Nvarchar(max) not null,
Matkhau Nvarchar(max) not null
)

go

create table Lienhe
(
Id int identity(1,1) primary key not null,
Tennguoilienhe Nvarchar(max) not null,
Diachiemail Nvarchar(max) not null,
Tieude Nvarchar(max) not null,
Noidung Nvarchar(max) not null
)

